<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/21
 * Time: 12:04
 */
namespace app\admin\controller;

use app\common\lib\Util;

class Image
{
    public function index()
    {
        $file = request()->file('file');
        if ($file) {
            $info = $file->move('../public/static/upload');
            if ($info) {
                $data = [
                    'image' => config('live.host') . '/upload/' . $info->getSaveName()
                ];
                return Util::show(config('code.success'), 'OK', $data);
            } else {
                return Util::show(config('code.error'), 'error');
            }
        }else{
            return Util::show(config('code.error'), 'img upload fail');
        }
    }
}